package com.lecture.java8.excel.dyr;

import com.alibaba.excel.EasyExcel;
import com.lecture.java8.excel.DemoDataListener;
import com.lecture.java8.excel.dyr.model.Result0329;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class Test0329 {
    public static void main(String[] args) {
        String dir = "D:\\study\\tmp\\0329\\";
        String dataResultFileName = dir + "上市公司金融科技发展指数测算数据（黄磊）2001-2022.xlsx";
        DemoDataListener<Result0329> dataResultListener = new DemoDataListener<>();
        EasyExcel.read(dataResultFileName, Result0329.class,dataResultListener).sheet().doRead();
        List<Result0329> resultList = dataResultListener.getDataList();

        List<String> typeList = resultList.stream().map(Result0329::getC).collect(Collectors.toList());
        Map<String, Long> map =
                typeList.stream().collect(Collectors.groupingBy(e -> e, Collectors.counting()));
        map.forEach((k,v) -> System.out.println(k+"-" + v));

        /*Map<String,String> resultMap = new HashMap<>();
        int i = 1;
        for (Result0329 result : resultList) {
            i++;
            if (result.getA().equals(9L)) {
                System.out.println(i+":::"+result.getA() + "----" + result.getB() + "----" + result.getC() );
            }
            resultMap.put(result.getA() + "-" + result.getB() ,result.getC());
        }
        //Map<String, String> resultMap = resultList.stream().collect(Collectors.toMap(r -> r.getId() + "-" + r.getYear(), Result0320::getEast));
*/


        /*String dataFileName = dir + "调整一次.xlsx";
        DemoDataListener<Model0329> dataListener = new DemoDataListener<>();
        EasyExcel.read(dataFileName, Model0329.class,dataListener).sheet().doRead();
        List<Model0329> financeList = dataListener.getDataList();
        for (Model0329 finance : financeList) {
            String s = resultMap.get(finance.getA() + "-" + finance.getB());
            finance.setT(s);
        }

        EasyExcel.write( dir + "0329-结果.xlsx", Model0329.class)
                .sheet("a").doWrite(financeList);*/

    }
}
